<template>
    <div
        class="userImage"
        :class="{
            userSelect: this.userType === 'userSelect',
            userDelete: this.userType === 'userDelete',
        }"
        :style="{
            background: `url(${$MMEV.userVipFS(
                compdata.userLevel || 1
            )}) 0% 0% / 100% no-repeat`,
        }"
        @click="handleClick"
    >
        <img class="userIcon" :src="$MMEV.userImgFS(compdata.userImage || 10)" />
        <div class="userName" v-if="!userNameDisabled">
            <span class="userText textEllipsis">
                {{ compdata.userName || '...' }}
            </span>
            <img src="@/assets/img/name01.png" />
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            dialogVisible: false,
        };
    },
    props: {
        compdata: {
            // 用户数据
            type: Object,
            default: () => {
                return {};
            },
        },
        userNameDisabled: {
            // 用户名是否显示
            type: Boolean,
            default: () => {
                return false;
            },
        },
        userType: {
            // 用户状态
            type: String,
            default: () => {
                return '';
            },
        },
    },
    methods: {
        handleClick(evt) {
            this.$emit('click', evt);
        },
    },
};
</script>
<style lang="scss" scoped>
// 暗夜
@media (prefers-color-scheme: dark) {
}

// 正常
@media (prefers-color-scheme: light) {
}

.userImage {
    width: 100%;
    height: 100%;
    background: url(../../assets/imgVip/v01.png) 0% 0% / 100% no-repeat;
    box-sizing: border-box;
    position: relative;
    filter: grayscale(50%);
    transition: filter 0.3s;
    &:hover {
        filter: grayscale(0%);
    }
    .userIcon {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        margin: auto;
        height: 75%;
        width: auto;
        display: block;
    }
    .userName {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 10%;
        margin: auto;
        width: 85%;
        img {
            width: 100%;
            height: auto;
        }
        .userText {
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            top: 0;
            margin: auto;
            font-weight: 600;
            font-size: 13px;
            line-height: 16px;
            text-align: center;
            width: 73%;
            height: 16px;
            color: #ffffff;
            text-shadow: 0px 2px 4px rgba(38, 36, 55, 0.29);
        }
    }
}
.userSelect {
    filter: grayscale(0%);
}
.userDelete {
    filter: grayscale(100%);
    &:hover {
        filter: grayscale(100%);
    }
}
</style>
